<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>密码找回-验证</title>
		<!-- Tell the browser to be responsive to screen width -->
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<!-- Bootstrap 3.3.5 -->
		<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
		<!-- Font Awesome -->
		<link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.5.0/css/font-awesome.css">
		<!-- Theme style -->
		<link rel="stylesheet" href="css/AdminLTE.css">
		<!-- AdminLTE Skins. We have chosen the skin-blue for this starter
          page. However, you can choose any other skin. Make sure you
          apply the skin class to the body tag so the changes take effect.
    -->
		<!--<link rel="stylesheet" href="css/skins/skin-blue.min.css">-->
		<link rel="stylesheet" type="text/css" href="css/ant-login.css" />

		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
        <script src="//cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
	</head>

	<body>
		<div id="" class="container">
			<div class="row">
				<div class="col-md-12 text-center">
					<img src="img/logo2.png" />
				</div>
			</div>
		</div>
		<div class="container ant-regcontainer">
			<div class="row">
				<div class="col-xs-12 text-center " style="border-top: #C87F0A 2px solid;">
					<!--<h3 class="color-y">集团律师验证</h3>-->
				</div>
			</div>
			<div class="row" style="padding-top: 40px;">
				<div class="col-md-6 col-md-offset-3">
					<div class="progress-group">
                        <div class="progress sm">
                        	
                        <span class="progress-text"></span>
                          <div class="progress-bar progress-bar-yellow" style="width: 33%"></div>
                        </div>
                      </div>
					<form action="jumptopasswordinput.action" name="form"class="form-horizontal regForm" method="post">
						<div class="form-group">
							<div class="col-sm-12">
								<div class="text-center">
									<label>
										<h3> 验证信息</h3>
									</label>
								</div>
							</div>
						</div>
						<div class="form-group has-feedback">
							<label for="phonenumber" class="col-sm-3 control-label">手机号码 *</label>
							<div class="col-sm-6">
								<input type="tel" name="phonenumber" maxlength="11" id="phonenumber" class="form-control" placeholder="手机号码" />
								<span class="glyphicon glyphicon-phone form-control-feedback"></span>
							</div>
							<div class="col-sm-3">

							</div>
						</div>
						<div class="form-group has-feedback">
							<label for="inputPassword3" class="col-sm-3 control-label">验证码 *</label>
							<div class="col-sm-3">
								<input type="text" class="form-control" maxlength="6" name="vertification" id="vertification" placeholder="验证码">
							</div>
							<div class="col-sm-3">
								<div class="col-sm-3"> 
								<input type="button" class="btn btn-primary" value="获取验证码" id="getvertification"> 
						 
							</div>
							</div>
							<div class="col-sm-3">
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-offset-3 col-sm-6">
								<div class="col-sm-offset-3 col-sm-6"> 
								<input type="button" class="btn btn-warning btn-block" value="确认" id="vertify"> 
								 
							</div>
							</div>
							<div class="col-sm-3">

							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
		<div class="hidden-xs">
			<div class="container" style="padding-top: 20px;">
				<a href="#" target="_blank">关于我们</a>|
				<a href="#" target="_blank">隐私条款</a>|
				<a href="#" target="_blank">社区规范</a>|
				<a href="#" target="_blank">用户反馈</a>|
				<a href="#" target="_blank">加入我们</a>|
				<a href="#" target="_blank">版权声明</a>
			</div>
		</div>
		<!--<nav class="  hidden-xs" style="  background: #2d3237;">
			<div class="container">
				<div class="row">
					<div class="col-md-6">
						<div class="row ant-footer">
							<div class="col-md-12" style="color: #fff;">
								<h3>
									InterLaw | <small>在线律师管理系统</small>            </h3>
							</div>
							<div class="col-md-12">
								<a href="#" target="_blank">关于我们</a>|
								<a href="#" target="_blank">隐私条款</a>|
								<a href="#" target="_blank">社区规范</a>|
								<a href="#" target="_blank">用户反馈</a>|
								<a href="#" target="_blank">加入我们</a>|
								<a href="#" target="_blank">版权声明</a>
								<br /> v
							</div>
						</div>
					</div>
					<div class="col-md-6">

					</div>

				</div>

			</div>
		</nav>-->
		<!--针对小屏幕显示-->
		<!--<div class="container visible-xs-inline-block">
			<div class="row">
				<div class="col-md-12">
					<a href="#" target="_blank">关于我们</a>|
					<a href="#" target="_blank">隐私条款</a>|
					<a href="#" target="_blank">社区规范</a>|
					<a href="#" target="_blank">用户反馈</a>|
					<a href="#" target="_blank">加入我们</a>|
					<a href="#" target="_blank">版权声明</a>
				</div>
			</div>
		</div>-->
		<!--针对小屏幕显示结束-->

		<!--<script src="jQuery/jQuery-2.1.4.min.js"></script>-->
		<script src="jQuery/jquery-1.11.2.min.js" type="text/javascript"></script>
		<!-- Bootstrap 3.3.5 -->
		<script src="bootstrap/js/bootstrap.min.js"></script>
		<!--<script type="text/javascript" src="js/login.js"></script>-->
		<script src="js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript"></script>
		<script>
  var phonenumber="";   //手机号
  var vertification="";  //用户输入的验证码
  //发送验证码时添加cookie
function addCookie(name,value,expiresHours){ 
    var cookieString=name+"="+escape(value); //获取剩余的秒数
    //判断是否设置过期时间,0代表关闭浏览器时失效
    if(expiresHours>0){ 
        var date=new Date(); 
        date.setTime(date.getTime()+expiresHours*1000); 
        cookieString=cookieString+";expires=" + date.toUTCString(); 
    } 
     	//alert("add cookieString "+cookieString);
        document.cookie=cookieString; 
} 
//修改cookie的值
function editCookie(name,value,expiresHours){ 
    var cookieString=name+"="+escape(value); 
    if(expiresHours>0){ 
      var date=new Date(); 
      date.setTime(date.getTime()+expiresHours*1000); //单位是毫秒
      cookieString=cookieString+";expires=" + date.toGMTString(); 
    } 
      document.cookie=cookieString; 
} 
//根据名字获取cookie的值
function getCookieValue(name){ 
      var strCookie=document.cookie; //getcookie
     // alert("get strCookie  "+strCookie)
      //var arrCookie=strCookie.split("="); //"="
//将多cookie切割为多个名/值对 
var arrCookie=strCookie.split("; "); 
//遍历cookie数组，处理每个cookie对 
for(var i=0;i<arrCookie.length;i++){ 
var arr=arrCookie[i].split("="); 
//找到名称为userId的cookie，并返回它的值 
if(name==arr[0]){ 
//alert(arr[1]);
return arr[1];
} 
}
return "undefined"; 
}


//发送验证码
function sendCode(){
 $.ajax({
type: "POST",
url:"vertify.action",	//把表单数据发送到ajax.jsp
dataType: "json", 	//返回数据类型
data:{
"phonenumber":phonenumber.value
},
async: true,
error: function(request) {
alert("发送请求失败！");
},
success: function(data) {
var json = eval("(" + data + ")"); 
if(json.respCode=="105122"){
alert("验证码发送次数超限，请明天再试");
//addCookie("secondsremained",60,60);//添加cookie记录,有效时间60s
//settime($("#getvertification"));//开始倒计时
}
else{
alert("如果长时间未收到短信，请重新点击获取验证码");
addCookie("secondsremained",60,60);//添加cookie记录,有效时间60s
settime($("#getvertification"));//开始倒计时应添加到上述else中，仅为调试方便
}
}
});

}
//开始倒计时
var countdown;
var t;
function settime(obj) { 
    countdown=getCookieValue("secondsremained");
 //   alert("countdown"+countdown);
    if (countdown == 1) { 
        obj.removeAttr('disabled');    
        obj.val("获取验证码"); 
        clearInterval(t);
        return;
    } else { 
        obj.attr('disabled', true); 
        obj.val("重新发送(" + countdown + ")"); 
        countdown--;
        editCookie("secondsremained",countdown,countdown+1);
    } 
    setTimeout(function() { settime(obj) },1000) //每1000毫秒执行一次
} 
  onload=function()
{
 phonenumber = document.getElementById("phonenumber");//js形式获得bieshehuile````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````			```````
 vertification = document.getElementById("vertification");   
}
  //  var jmz = {};
//	jmz.GetLength = function(str) {
  //  return str.replace(/[\u0391-\uFFE5]/g,"aa").length;
//	}; 
        $(document).ready(function(){  //页面加载完成即执行
        $("#getvertification").click(function(){//获取验证码响应JQuery
         onload();//加载phonenumber,vertification
         //检验手机号是否违法
        var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/; //正则表达式
		if(!myreg.test(phonenumber.value)) //不匹配的情况
		{ 
		  	 alert("请输入有效的手机号码！"); 
		   	return false; 
		} 
         sendCode(); // ajax发送数据  
});     //验证按钮响应        
        $("#vertify").click(function(){//
         onload();		//加载函数
    		if(vertification.value==null||vertification.value==""){
    			alert("请输入验证码");  //验证码不能为空
    			return;
    		}
         $.ajax({  //提交ajax数据
type: "POST",
url:"vertifyfindpasswordback.action",	//把表单数据发送到ajax.jsp
dataType: "json", 
data:{
"phonenumber":phonenumber.value,
"vertification":$("input[name='vertification']").val()//JQuery形式
},
async: true,
error: function(request) {
alert("发送请求失败！");
},
success: function(data) {

var json = eval("(" + data + ")"); //获得json数据返回
if(json.code=="true"){ //判断是否验证成功
document.form.submit();
}else if(json.code=="noexist"){
	alert("账户名不存在，手机号就是您的账户名");//账户名不存在，手机号就是您的账户名
}
else{
	alert("验证码错误，请重新输入");//验证错误
}
}
});       
});   
//用于上次计时未结束时
var v = getCookieValue("secondsremained");//获取cookie值
if(v!="NaN"&&v!="undefined"){
settime($("#getvertification"));//上次刷新之前处于倒计时状态，则继续倒计时
}
});   
  </script >
	</body>

</html>